home *** CD-ROM | disk | FTP | other *** search
- import javax.microedition.lcdui.Command;
- import javax.microedition.lcdui.CommandListener;
- import javax.microedition.lcdui.Display;
- import javax.microedition.lcdui.Displayable;
- import javax.microedition.midlet.MIDlet;
- import javax.microedition.midlet.MIDletStateChangeException;
-
- public class Blocks extends MIDlet implements CommandListener {
- private Command startCommand = new Command("Start", 1, 1);
- private Command goCommand = new Command("Go", 1, 1);
- private Command exitCommand = new Command("Exit", 1, 1);
- private Command restartCommand = new Command("Restart", 1, 1);
- private BlocksCanvas bcanvas;
- private BlocksHelp bhelp = new BlocksHelp(this);
-
- public Blocks() {
- this.bhelp.addCommand(this.goCommand);
- this.bhelp.addCommand(this.exitCommand);
- this.bhelp.setCommandListener(this);
- this.bcanvas = new BlocksCanvas(this);
- this.bcanvas.addCommand(this.startCommand);
- this.bcanvas.addCommand(this.exitCommand);
- this.bcanvas.setCommandListener(this);
- }
-
- public void startApp() throws MIDletStateChangeException {
- Display.getDisplay(this).setCurrent(this.bhelp);
- }
-
- public void pauseApp() {
- }
-
- public void destroyApp(boolean uncond) {
- }
-
- public void commandAction(Command c, Displayable d) {
- if (c == this.startCommand) {
- this.bcanvas.removeCommand(this.startCommand);
- this.bcanvas.removeCommand(this.exitCommand);
- this.bcanvas.addCommand(this.restartCommand);
- this.bcanvas.addCommand(this.exitCommand);
- this.bcanvas.start();
- } else if (c == this.goCommand) {
- Display.getDisplay(this).setCurrent(this.bcanvas);
- this.bhelp = null;
- } else if (c == this.restartCommand) {
- this.bcanvas.restartGame();
- } else if (c == this.exitCommand) {
- this.destroyApp(false);
- ((MIDlet)this).notifyDestroyed();
- }
-
- }
- }
-